﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.UI;
using System.Web;
using System.Web.UI.WebControls;

namespace SistemaAcademicoBLL.Util
{
    public class Alert
    {
        public static void Show(string message)
        {
            Page page = HttpContext.Current.CurrentHandler as Page;

            Panel pnlMessageBox = new Panel();

            pnlMessageBox.ID = "pnlMessageBox";
            pnlMessageBox.Style["display"] = "none";

            Label lblMessage = new Label();

            lblMessage.ID = "lblMessage";
            lblMessage.Text = message;

            pnlMessageBox.Controls.Add(lblMessage);
            page.Form.Controls.Add(pnlMessageBox);

            ClientScriptManager clientScriptManager = page.ClientScript;

            Type pageType = page.GetType();
            string scriptName = "FaceboxScript";

            if (!clientScriptManager.IsStartupScriptRegistered(pageType, scriptName))
            {
                string scriptText = "jQuery.facebox({ div: '#" + pnlMessageBox.ClientID + "' });";

                clientScriptManager.RegisterStartupScript(pageType, scriptName, scriptText, true);
            }
        }

        public static void Facebox(Type type, Label lblAlert, String msg)
        {
            Page page = HttpContext.Current.CurrentHandler as Page;
            lblAlert.Text = msg;
            page.ClientScript.RegisterStartupScript(type, "facebox", "<script> jQuery.facebox({ div: '#box' }, 'my-groovy-style'); </script>");
        }
    }
}
